#!/bin/bash

# 检查IPv4数据包重定向发送是否已禁用
if [[ $(sysctl -n net.ipv4.conf.all.send_redirects 2>/dev/null) -eq 0 ]]; then
    echo "通过：IPv4 all send_redirects 已禁用"
else
    echo "失败：IPv4 all send_redirects 未禁用"
    exit 1
fi

if [[ $(sysctl -n net.ipv4.conf.default.send_redirects 2>/dev/null) -eq 0 ]]; then
    echo "通过：IPv4 default send_redirects 已禁用"
else
    echo "失败：IPv4 default send_redirects 未禁用"
    exit 1
fi

# 检查IPv6数据包重定向接收是否已禁用
if [[ $(sysctl -n net.ipv6.conf.all.accept_redirects 2>/dev/null) -eq 0 ]]; then
    echo "通过：IPv6 all accept_redirects 已禁用"
else
    echo "失败：IPv6 all accept_redirects 未禁用"
    exit 1
fi

if [[ $(sysctl -n net.ipv6.conf.default.accept_redirects 2>/dev/null) -eq 0 ]]; then
    echo "通过：IPv6 default accept_redirects 已禁用"
else
    echo "失败：IPv6 default accept_redirects 未禁用"
    exit 1
fi
